<template>
  <div>
    <div class="box" v-if="isEmpty">
      <el-card>
        <div class="post" v-for="(item,index) in files">
          <h3 class="post-title"><a href="#" @click="jump(item)">{{ item.name }}</a></h3>
          <p class="post-meta">{{ item.publisher }}，发布于 {{ item.createTime }}</p>
        </div>
      </el-card>
    </div>
    <div v-else class="empty">
      没搜到哦~~
    </div>
  </div>
</template>

<script>
export default {
  name: "SearchVideo",
  data() {
    return {
      files: [],
      isEmpty: false,
      input: this.$route.query.obj
    }
  },
  methods: {
    jump(item){
      let routeUrl = this.$router.resolve({
        path: "/showArticles",
        query:{
          id:item.id,
          userId:item.userId
        }
      })
      window.open(routeUrl.href, '_blank')
    },
    getList() {
      let userId = this.$sessionGet().id;
      this.$axios.get("resource/searchFileLike?obj="+ this.input)
          .then(resp => {
            let res = resp.data;
            let length = res.data.length
            if(length !== 0){
              this.isEmpty = true;
            }
            console.log(res.data)
            this.files = res.data;
          })
          .catch(error => {
            console.log(error)
          })
    }
  },
  created() {
    this.getList();
  }
}
</script>

<style scoped>

.box{
  height: 100%;
}
.left img{
  height: 80px;
  width: 80px;
}

.bottom p{
  margin: 10px;
  font-size: 10px;
}
a {
  color: #333;
  text-decoration: none;
}
section {
  background-color: #fff;
  padding: 20px;
  margin: 20px;
  text-align: left;
}
h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.post {
  margin-bottom: 20px;
}
.post-title {
  font-size: 18px;
  margin-bottom: 7px;
  text-align: left;
}
a:hover{
  color: cornflowerblue;
}
.post-meta {
  font-size: 14px;
  color: #999;
  display: flex;
  align-items: center;
  margin-bottom: 7px;
}
.post-text{
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  text-align: left;
  -webkit-box-orient: vertical;
}
.author-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 10px;
}
</style>